package com.hrc.springbootdemo.minio;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/minio")
@Slf4j
@AllArgsConstructor
@Tag(name = "minio")
public class MinioController {

    private final MinioService minioService;

    @PostMapping("/upload")
    @Operation(summary = "uploadFile")
    public String uploadFile(String fileName, MultipartFile file) throws Exception {
            return   minioService.uploadFile(fileName,file);
    }

    @GetMapping("/getUrl")
    public String getPresignedUrl(String fileName) throws Exception {
        return minioService.getPresignedUrl(fileName);
    }
}
